﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using umbraco.cms.businesslogic.member;

namespace ContourStrikesAgain.Controls
{
   [System.Web.UI.ValidationProperty("Value")]
    public class MemberLogin : TextBox
    {

       protected override void OnLoad(EventArgs e)
       {
           base.OnLoad(e);

           this.CssClass = "memberlogin";

          
           Page.ClientScript.RegisterClientScriptInclude(
               "ContourStrikesAgain.Resources.Scripts.uniqueMemberLogin.js",
               Page.ClientScript.GetWebResourceUrl(Page.GetType(), "ContourStrikesAgain.Resources.Scripts.uniqueMemberLogin.js"));

       }


        public string Value
        {
            get
            {
                if (!string.IsNullOrEmpty(this.Text))
                {

                    if (Member.GetMemberFromLoginName(this.Text) == null)
                        return this.Text;
                    else
                        return string.Empty;
                }
                else
                    return string.Empty;
            }
            set
            {
                this.Text = value;
            }

        }
    }
}